package com.company.project.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.company.project.common.aop.annotation.LogAnnotation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.List;
import com.company.project.common.utils.DataResult;

import com.company.project.entity.TThrbEntity;
import com.company.project.service.TThrbService;



/**
 * 
 * 通话日报
 * @author
 * @email *****@mail.com
 * @date 2023-11-06 22:00:19
 */
@Controller
@RequestMapping("/")
public class TThrbController {
    @Autowired
    private TThrbService tThrbService;


    /**
    * 跳转到页面
    */
    @GetMapping("/index/tThrb")
    public String tThrb() {
        return "tthrb/list";
        }

    @ApiOperation(value = "新增")
    @PostMapping("tThrb/add")
    @RequiresPermissions("tThrb:add")
    @ResponseBody
    public DataResult add(@RequestBody TThrbEntity tThrb){
        tThrbService.save(tThrb);
        return DataResult.success();
    }

    @ApiOperation(value = "删除")
    @DeleteMapping("tThrb/delete")
    @RequiresPermissions("tThrb:delete")
    @ResponseBody
    public DataResult delete(@RequestBody @ApiParam(value = "id集合") List<String> ids){
        tThrbService.removeByIds(ids);
        return DataResult.success();
    }

    @ApiOperation(value = "更新")
    @PutMapping("tThrb/update")
    @RequiresPermissions("tThrb:update")
    @ResponseBody
    public DataResult update(@RequestBody TThrbEntity tThrb){
        tThrbService.updateById(tThrb);
        return DataResult.success();
    }

    @ApiOperation(value = "查询分页数据")
    @PostMapping("tThrb/listByPage")
    @LogAnnotation(title = "通话日报", action = "查询分页数据")
    @RequiresPermissions("tThrb:list")
    @ResponseBody
    public DataResult findListByPage(@RequestBody TThrbEntity tThrb){
        Page page = new Page(tThrb.getPage(), tThrb.getLimit());
        LambdaQueryWrapper<TThrbEntity> queryWrapper = Wrappers.lambdaQuery();
        //查询条件示例
        //queryWrapper.eq(TThrbEntity::getId, tThrb.getId());
        //IPage<TThrbEntity> iPage = tThrbService.page(page, queryWrapper);
        return tThrbService.listByPage(page, tThrb);
    }
    @ApiOperation(value = "查询初始化选项")
    @LogAnnotation(title = "通话日报", action = "查询初始化选项")
    @GetMapping("tThrb/infoData")
    //@RequiresPermissions("tHwtj:list")
    @ResponseBody
    public DataResult infoData(){
        return tThrbService.infoData();
    }
}
